package com.fr.chart.axis;

import com.fr.base.StringUtils;
import com.fr.base.core.json.JSONException;
import com.fr.base.core.json.JSONObject;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLReadable;
import com.fr.base.xml.XMLableReader;
import com.fr.chart.DataSeriesCondition;
import com.fr.chart.base.equals.Equals;
import com.fr.chart.core.ChartUtils;
import com.fr.report.io.xml.ReportXMLUtils;
import java.text.DecimalFormat;
import java.text.Format;

public class SeriesAttrStyle
  implements DataSeriesCondition
{
  private static final long serialVersionUID = 5328560572564949184L;
  public static final String XML_TAG = "SeriesAttrStyle";
  private String separation = ",";
  private TextAttr textAttr = null;
  private Format format = null;
  private Format percentFormat = null;

  public void setSeparation(String paramString)
  {
    this.separation = paramString;
  }

  public String getSeparation()
  {
    return this.separation;
  }

  public void setTextAttr(TextAttr paramTextAttr)
  {
    this.textAttr = paramTextAttr;
  }

  public TextAttr getTextAttr()
  {
    return this.textAttr;
  }

  public void setFormat(Format paramFormat)
  {
    this.format = paramFormat;
  }

  public Format getFormat()
  {
    return this.format;
  }

  public void setPercentFormat(Format paramFormat)
  {
    if (paramFormat instanceof DecimalFormat)
      this.percentFormat = paramFormat;
  }

  public Format getPercentFormat()
  {
    return this.percentFormat;
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    if (paramXMLableReader.isChildNode())
    {
      String str = paramXMLableReader.getTagName();
      if ("Separation".equals(str))
        setSeparation(paramXMLableReader.getElementValue());
      else if ("TextAttr".equals(str))
        setTextAttr((TextAttr)paramXMLableReader.readXMLObject(new TextAttr()));
      else if ("Format".equals(str))
        setFormat(ReportXMLUtils.readFormat(paramXMLableReader));
      else if ("PercentFormat".equals(str))
        paramXMLableReader.readXMLObject(new XMLReadable(this)
        {
          private final SeriesAttrStyle this$0;

          public void readXML()
          {
            if ((paramXMLableReader.isChildNode()) && ("Format".equals(paramXMLableReader.getTagName())))
              this.this$0.setPercentFormat(ReportXMLUtils.readFormat(paramXMLableReader));
          }
        });
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    paramXMLPrintWriter.startTAG("SeriesAttrStyle");
    if (StringUtils.isNotEmpty(this.separation))
      paramXMLPrintWriter.startTAG("Separation").textNode(this.separation).end();
    if (this.textAttr != null)
      this.textAttr.writeXML(paramXMLPrintWriter);
    if (this.format != null)
      ReportXMLUtils.writeFormat(paramXMLPrintWriter, this.format);
    if (this.percentFormat != null)
    {
      paramXMLPrintWriter.startTAG("PercentFormat");
      ReportXMLUtils.writeFormat(paramXMLPrintWriter, this.percentFormat);
      paramXMLPrintWriter.end();
    }
    paramXMLPrintWriter.end();
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    SeriesAttrStyle localSeriesAttrStyle = (SeriesAttrStyle)super.clone();
    if (this.format != null)
      localSeriesAttrStyle.format = ((Format)this.format.clone());
    if (this.textAttr != null)
      localSeriesAttrStyle.textAttr = ((TextAttr)this.textAttr.clone());
    if (this.percentFormat != null)
      localSeriesAttrStyle.percentFormat = ((Format)this.percentFormat.clone());
    return localSeriesAttrStyle;
  }

  public boolean equals(Object paramObject)
  {
    if (!(paramObject instanceof SeriesAttrStyle))
      return false;
    SeriesAttrStyle localSeriesAttrStyle = (SeriesAttrStyle)paramObject;
    if (!(Equals.equals(localSeriesAttrStyle.format, this.format)))
      return false;
    if (!(Equals.equals(localSeriesAttrStyle.separation, this.separation)))
      return false;
    if (!(Equals.equals(localSeriesAttrStyle.textAttr, this.textAttr)))
      return false;
    return (Equals.equals(localSeriesAttrStyle.percentFormat, this.percentFormat));
  }

  public JSONObject toJSONObject()
    throws JSONException
  {
    JSONObject localJSONObject = new JSONObject();
    localJSONObject.put("separation", this.separation);
    if (this.format != null)
      localJSONObject.put("format", ChartUtils.format2JS(this.format));
    if (this.textAttr != null)
      localJSONObject.put("textAttr", this.textAttr.toJSONObject());
    if (this.percentFormat != null)
      localJSONObject.put("percentFormat", ChartUtils.format2JS(this.percentFormat));
    return localJSONObject;
  }

  public String getConditionType()
  {
    return "SeriesAttrStyle";
  }
}